package com.akuhome.resource.controller;

import com.akuhome.resource.DO.Approve;
import com.akuhome.resource.enums.NeedType;
import com.akuhome.resource.service.ApproveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/approve")
public class ApproveController {

    @Autowired
    ApproveService approveService;

    @GetMapping
    public Object getApprove(String uid,Integer type){
        if(type == null){
            return approveService.findApproveByProjectUId(uid);
        }else{
            return approveService.findApproveByProjectUIdAndType(uid,NeedType.valueOf(type));
        }
    }

    @PutMapping
    public Object submitApprove(@RequestBody Approve approve){
        approveService.submitApprove(approve);
        return null;
    }
}
